﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using BSCMFF.Core;

namespace BSCMFF.Web.Pages.Evaluation_Setup.Personalist
{
    /// <summary>
    /// Manage evaluation periods.
    /// </summary>
    /// <remarks></remarks>
    public partial class ManageEvaluations : MultiLanguagePage
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected void Page_Load(object sender, EventArgs e)
        {
            RadGrid1.Culture = System.Threading.Thread.CurrentThread.CurrentCulture;
        }

        /// <summary>
        /// Handles the ItemCommand event of the RadGrid1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {          
            if (e.Item.ItemIndex != -1 && e.CommandName == "Edit" )
            {
                int id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
                Response.Redirect("EvaluationEditMode.aspx?EvaluationID=" + id + "&Command=" + e.CommandName);

            }
            if(e.CommandName == "InitInsert")
            {
                Response.Redirect("EvaluationEditMode.aspx?Command=" + e.CommandName);
            }

            if (e.Item.ItemIndex != -1 && e.CommandName == "Select")
            {
                int id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
                Response.Redirect("../EvaluationFillingMode.aspx?EvaluationID=" + id.ToString());
            }
        }
    }
}